<?php
/**
 * @package Joomla
 * @subpackage Jmonoslideshow
 * @copyright (C) 2010 - Matthieu BARBE - www.ccomca.com
 * @license GNU/GPL v2
 * 
 * Jmonoslideshow is a Joomla extension for Monoslideshow.
 *
 * Jmonoslideshow uses :
 * Monoslideshow (http://www.monoslideshow.com/)
 * Plupload (http://www.plupload.com/) by Moxicode Systems
 * json class by Michal Migurski, Matt Knapp, Brett Stimmerman
 * jquery a JavaScript Library (http://jquery.com/)
 * getid3 library (http://getid3.sourceforge.net/)
 * swfobject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file (http://code.google.com/p/swfobject/)
 * Chained Selects jQuery Plugin (http://www.appelsiini.net/2010/jquery-chained-selects)
 *
 * Jmonoslideshow is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the Monoslideshow Component
 *
 * @package    Monoslideshow
 * @subpackage Views
 */

class JmonoslideshowViewImages extends JView
{
	/**
	 * Monoslideshows view display method
	 * @return void
	 **/
	function display($tpl = null)
	{
		
		global $option;
		
		JToolBarHelper::title(   JText::_( 'COM_JMONOSLIDESHOW_JMONOSLIDESHOW_MANAGER' ), 'media' );
		JToolBarHelper::publishList();
		JToolBarHelper::unpublishList();
		JToolBarHelper::deleteList();
		JToolBarHelper::editListX();
		JToolBarHelper::addNewX();
		JToolBarHelper::preferences('com_jmonoslideshow', '500');
		
		$mainframe =& JFactory::getApplication();
		$filter_catid		= $mainframe->getUserStateFromRequest( $option.'filter_catid',		'filter_catid',		0,				'int' );
		$filter_state		= $mainframe->getUserStateFromRequest( $option.'filter_state',		'filter_state',		'',				'word' );
		$filter_order		= $mainframe->getUserStateFromRequest( $option.'filter_order',		'filter_order',		'a.ordering',	'cmd' );
		$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.'filter_order_Dir',	'filter_order_Dir',	'',				'word' );
		$search				= $mainframe->getUserStateFromRequest( $option.'search',			'search',			'',				'string' );
		$search				= JString::strtolower( $search );
		
		//load categories model
		require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jmonoslideshow'.DS.'models'.DS.'categories.php' );
		$categories_model = new JmonoslideshowModelCategories();
		
		//load list html for categories 
		$list_categories = $categories_model->getListForHtml( JText::_( 'COM_JMONOSLIDESHOW_SELECT_A_CATEGORY' ));
		$lists['catid'] = JHTML::_('select.genericlist', $list_categories , 'filter_catid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"' , 'value', 'text',  $mainframe->getUserStateFromRequest( 'filter_catid', 'filter_catid', '', 'int' ));
		// state filter
		$lists['state']	= JHTML::_('grid.state',  $filter_state );
		
		//type filter
		$typeTranslations = array(
		    '3'         => 'Select Type' , 
	        '2'   		=> 'Video',
			'1'    		=> 'Flash',
			'0'    		=> 'Image' 
	    );

        $options = array();

        foreach ( $typeTranslations as $type => $translation ) {
        	$options[] = JHTML::_('select.option', $type, JText::_( $translation ) );
        }
         
        $selectTypeList = JHTML::_( 'select.genericlist',
                                     $options,
	                                 'type', 
	                                 'class="inputbox" size="1" onchange="document.adminForm.submit();"' , 
	                                 'value', 
	                                 'text', 
                                      $mainframe->getUserStateFromRequest( 'type', 'type', 3, 'int' )
                                    );
		
		// search filter
		$lists['search']= $search;
		
		// table ordering
		$lists['order_Dir'] = $filter_order_Dir;
		$lists['order'] = $filter_order;
		
		// Get data from the model
	 	$items =& $this->get('Data');	
	 	$pagination =& $this->get('Pagination');
	
		// push data into the template
		$this->assignRef('user', JFactory::getUser());
		$this->assignRef('items', $items);
		$this->assignRef('lists',		$lists);
		$this->assignRef('selectTypeList' , $selectTypeList );
		$this->assignRef('pagination', $pagination);

		parent::display($tpl);
	}//function

}//class